package com.cloud.lawcase.controller;

import com.cloud.lawcase.entity.Case;
import com.cloud.lawcase.service.CaseService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
public class CaseController {
    @Autowired
    private CaseService caseService;
    /**
     * 添加案件信息
     */
    @ApiOperation(value = "添加案件信息")
    @PostMapping("/saveCase")
    public void save(@RequestBody Case cases) {
        cases.setCreateTime(new Date());
        caseService.save(cases);
    }

    /**
     * 根据案件id删除案件信息
     * @param id
     */
    @ApiOperation("根据案件id删除案件信息")
    @DeleteMapping("/deleteCase/{id}")
    public void delete(@PathVariable Integer id) {
        caseService.removeById(id);
    }

    /**
     * 查询案件信息
     * @param
     * @return
     */
    @ApiOperation("查询所有案件信息")
    @GetMapping("/findAllCase")
    public List<Case> findALLCases() {
        return caseService.list();
    }
    /**
     * 修改案件信息
     * @param cases
     */
    @PutMapping("/updateCase")
    public void put(@RequestBody Case cases) {
        cases.setUpdateTime(new Date());
        caseService.updateById(cases);
    }
}
